package com.apes.hr.base.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.frame.model.Branch;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 功能：编制调整计划明细
 * @author HuJianlin
 * @create 2018-04-25 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = StaffPlanItem.CONST_TABLE_NAME)
public class StaffPlanItem extends BaseModel {
    public static final String CONST_TABLE_NAME = "hr_staff_plan_item";

    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "staff_plan_id", referencedColumnName = "id")
    private StaffPlan staffPlans; //关联主表

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "编制调整计划明细")
    private long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "branch_id", referencedColumnName = "id")
    private Branch branch; //工作部门-行政部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "workPost_id", referencedColumnName = "id")
    private WorkPost workPost; // 岗位

    @Column(name = "old_qty", nullable = false, columnDefinition = "number(8,0) default 0")
    private int oldQty = 0;  //原定编人数

    @Column(name = "real_qty", nullable = false, columnDefinition = "number(8,0) default 0")
    private int realQty = 0;  //实际人数

    @Column(name = "plan_qty", nullable = false, columnDefinition = "number(8,0) default 0")
    private int planQty = 0;  //新定编人数

    @Name
    @Column(name = "stop_recruit_qty", nullable = false, columnDefinition = "number(8,0) default 0")
    private int stopRecruitQty = 0;  //暂停招聘人数

    @Column(name = "DESCRIPTION", length = 500)
    private String description; //说明
}
